package com.barunlab.ems.client.main;

import java.util.ArrayList;

import org.apache.log4j.Logger;

import com.barunlab.ems.client.control.ClientManager;
import com.barunlab.ems.model.EmsResult;
import com.barunlab.ems.model.UserInfo;

public class ClientMain {
	private static Logger LOGGER = Logger.getLogger(ClientMain.class);

	public ClientMain(String[] args) {
		try {
			init();
		}
		catch (Exception ex) {
			LOGGER.error(ex.getMessage(), ex);
		}
	}
	
	private void init() throws Exception {
		EmsResult result = ClientManager.login("root", "root");
		LOGGER.debug(String.format("login result:%s", result.getType()));
		
		result = ClientManager.getUserInfo(null);
		Object[] params = result.getParams();
		
		ArrayList<UserInfo> userInfoList = (ArrayList<UserInfo>)params[0];
		for ( UserInfo oneUserInfo : userInfoList ) {
			LOGGER.debug(String.format("UserInfo id:%s, password:%s, level:%s", 
					oneUserInfo.getId(), oneUserInfo.getPassword(), oneUserInfo.getLevel()));
		}
	}
	
	public static void main(String[] args) {
		new ClientMain(args);
	}
}
